<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
	Random random = new Random();
%>
<%
	ArrayList al = new ArrayList();
	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	String connectionUrl = "jdbc:sqlserver://localhost:1438;database=HKBANK;user=sa;password=1111";
	Connection conn = DriverManager.getConnection(connectionUrl);
	Statement stmt = conn
			.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
					ResultSet.CONCUR_UPDATABLE);
	String sql = "select top 100 * from dbo.last order by id desc";
	ResultSet rs = stmt.executeQuery(sql);
	while (rs.next()) {
%>
<%
	al.add(rs.getDouble("ftse"));
%>
<%
	}
%>

<%
	double max = Double.MAX_VALUE;
	double min = 0;
	for (int i = 0; i < al.size(); i++) {
		double doublevalue = ((Double) al.get(i)).doubleValue();
		if (doublevalue > max) {
			max = doublevalue;
		}
		if (doublevalue < min) {
			min = doublevalue;
		}
	}
	//out.println(al.size());
	rs.close();
	stmt.close();
	conn.close();
	////src="http://chart.apis.google.com/chart?chxr=0,0,50,1&chxt=y,x&chs=440x220&cht=lxy&chco=FF0000&chd=t:-1|<%for (int i = 0; i < al.size(); i++) {
%>
<img
	src="http://chart.apis.google.com/chart?chxr=0,0,8000&chxt=y,x&chs=440x220&cht=lxy&chco=FF0000&chd=t:-1|<%for (int i = 0; i < al.size(); i++) {
				Double temp = (Double) al.get(i);
				double t = temp.doubleValue() ;
				if (i < al.size() - 1) {
					out.println(al.get(i) + ",");
					//out.println(t + ",");
				} else {
					out.println(al.get(i));
					//out.println(t);
				}

			}%>&chdl=Hang Seng Index&chdlp=b&chls=1&chma=5,5,5,25&chds=4000,8000" />

</body>
</html>